<template>
  <div class="vehicle-detail">
    <el-page-header content="详情页面" @back="goBack" />
    <el-row class="aside-box">
      <el-col :span="24" class="aside-item">
        <div class="aside-item-for">
          <div class="aside-item-box">
            <span :class="{ activeIndex: selected === 0 }" @click="selected = 0">基本信息</span>
          </div>
          <div class="aside-item-box">
            <span :class="{ activeIndex: selected === 1 }" @click="selected = 1">行驶证信息</span>
          </div>
        </div>
      </el-col>
      <el-col :span="24">
        <div class="el-card__body">
          <el-form ref="userInfo" :model="userInfo" label-width="80px">
            <el-col :span="8">
              <div>
                <el-form-item label="车辆编号:" prop="id">
                  <el-input
                    v-model="userInfo.id"
                    class="no-border"
                    style="width: 300px"
                    disabled
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div>
                <el-form-item label="车辆号码:" prop="licensePlate">
                  <el-input
                    v-model="userInfo.licensePlate"
                    class="no-border"
                    style="width: 300px"
                    disabled
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div>
                <el-form-item label="车型名称:" prop="truckTypeName">
                  <el-input
                    v-model="userInfo.truckTypeName"
                    class="no-border"
                    style="width: 300px"
                    disabled
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div>
                <el-form-item label="车辆体积:" prop="allowableVolume">
                  <el-input
                    v-model="userInfo.allowableVolume"
                    class="no-border"
                    style="width: 61px"
                    disabled
                  >
                    <span slot="suffix">m³</span>
                  </el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div>
                <el-form-item label="车辆载重:" prop="allowableLoad">
                  <el-input
                    v-model="userInfo.allowableLoad"
                    class="no-border"
                    style="width: 102px"
                    disabled
                  >
                    <span slot="suffix">吨</span>
                  </el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div>
                <el-form-item label="GPSID:" prop="deviceGpsId">
                  <el-input
                    v-model="userInfo.deviceGpsId"
                    class="no-border"
                    style="width: 300px"
                    disabled
                  />
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div>
                <el-form-item label="图片信息:">
                  <ImageUpload />
                </el-form-item>
              </div>
            </el-col>
          </el-form>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { getVehicleId } from '@/api/vehicle'
import ImageUpload from './components/image-upload.vue'
export default {
  name: 'VehicleDetail',
  components: { ImageUpload },
  data() {
    return {
      userInfo: {},
      selected: -1
    }
  },
  async created() {
    const id = this.$route.params.id
    console.log('id', id)
    // 没有id趁早返回
    if (!id) return
    const res = await getVehicleId(id)
    console.log(res.data)
    this.userInfo = res.data
  },
  methods: {
    goBack() {
      this.$router.back()
    }
  }

}
</script>

<style lang="scss">
.el-page-header {
   padding: 25px 20px 0;
   margin-bottom: 23px;
}
.aside-box {
  padding: 24px 37px;
  background-color: #fff;
  .aside-item {
    border-radius: 4px;
    background-color: #fff;
    height: 36px;
    border-bottom: 1px solid #e5e7ec;
    .aside-item-for {
        display: flex;
        font-size: 16px;
        font-weight: 700;
        color: #20232a;
        position: relative;
        .aside-item-box {
        margin-right: 53px;
        padding-left: 25px;
        cursor: pointer;
        }
    }
  }
  .el-card__body {
    height: 500px;
  }
}
.activeIndex::after {
    content: '';
    display: block;
    background-color: #e15536;
    height: 3px;
    width: 53px;
    margin: 0 auto;
    position: relative;
    bottom: -15px;
    left: 2%;
}
.no-border .el-input__inner {
    border: none; /*去掉边框*/
    background-color: #fff;
}
.el-input.is-disabled .el-input__inner {
  background-color: #fff; /*将输入框背景色设置为灰色*/
  color: #333; /*将输入框文字颜色设置为黑色*/
  border-color: transparent; /*将输入框边框颜色设置为透明*/
}
</style>
